﻿<!DOCTYPE HTML>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head th:include="/common/head :: commonHead('车位列表')">
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 车次管理 <span class="c-gray en">&gt;</span> 车次列表
<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i id="shuaxin" class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c">
	<form action="/admin/findCarByKey">
		<input type="text" th:value="${keyTmp}" class="input-text" style="width:250px" placeholder="输入车位编号" name="keyTmp" />
		<button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜车位</button>
	</form>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
	<span class="l">
	<a href="javascript:;" onclick="car_add('添加车位','/admin/car-add','1000','500')" class="btn btn-primary radius">
	<i class="Hui-iconfont">&#xe600;</i> 添加车位</a></span>
	<span class="r">共有数据：<strong th:text="${carNum}"></strong> 条</span> </div>
	<table class="table table-border table-bordered table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="9">车次列表</th>
			</tr>
			<tr class="text-c">
				<th width="45">序号</th>
				<th width="100">车位编号</th>
				<th width="100">车位价格</th>
				<th width="100">车位状态</th>
				<th width="100">地址</th>
				<th width="100">地址经度</th>
				<th width="100">地址纬度</th>
				<th width="100">操作</th>
			</tr>
		</thead>
		<tbody>
			<tr class="text-c" th:each="car,carStat : ${carList}">
				<td>
				<span th:text="${carStat.index+1}"></span>
				<input type="hidden" th:value="${car.id}" class="inp"/>
				</td>
				<td th:text="${car.name}"></td>
				<td th:text="${car.price}"></td>
				<td class="td-status">
				<span class="label label-success radius"  th:if="${car.status}==0">空置</span>
				<span class="label radius" th:if="${car.status}!=0">已预约</span></td>


                <td th:text="${car.address}"></td>
                <td th:text="${car.addressLat}"></td>
                <td th:text="${car.addressLon}"></td>
				<td class="td-manage">
				<a style="text-decoration:none" class="ml-5" onClick="car_edit(this,'车次编辑','/admin/car-edit','800','400')" href="javascript:;" title="编辑">
				<i class="Hui-iconfont">&#xe6df;</i></a>
				<a title="删除" href="javascript:;" onclick="car_del(this)"
				class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
				</td>
			</tr>
		</tbody>
	</table>
</div>

<!-- 引入公共js -->
<span th:include="/common/on-load-js :: commonOnLoadJs"></span>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">

function car_add(title,url,w,h){
	layer_show(title,url,w,h);
}

function car_edit(obj,title,url,w,h){
	var carId = $(obj).parents("tr").find(".inp").val();
	var urltmp = url+"?carId="+carId;
	layer_show(title,urltmp,w,h);
}

function car_del(obj){
	layer.confirm('确认要删除吗？',function(index){
		var carId = $(obj).parents("tr").find(".inp").val();
		$.ajax({
			type: 'POST',
			url: '/admin/delCar',
			data:{"carId":carId},
			dataType: 'json',
			success: function(data){
				if(data.res==0){
					$(obj).parents("tr").remove();
					layer.msg('已删除!',{icon:1,time:1000});
				}else{
					layer.msg('操作失败!',{icon: 2,time:1000});
				}
			}
		});		
	});
}
</script>
</body>
</html>